<?php
/*
 * 用户验证
*/
namespace App\Validation;

use Phalcon\Validation\Validator\PresenceOf;
use Phalcon\Validation\Validator\Numericality;

class UseraddValidation extends BaseValidation
{
    public function initialize()
    {
		$this->add(
			"nickname",
			new PresenceOf(
				 [
                      "message" => "The nickname is required",
                      "allowEmpty" => true,
                  ]
			)
		);
		
		$this->add(
			"address",
			new PresenceOf(
				  [
					  "message" => "The address is required",
					  "allowEmpty" => true,
				  ]
			)
		);
		
		$this->add(
			"sex",
			new PresenceOf(
				  [
					  "message" => "The sex is required",
					  "allowEmpty" => true,
				  ]
			)
		);

		$this->add(
			"sign",
			new PresenceOf(
				  [
					  "message" => "The sign is required",
					  "allowEmpty" => true,
				  ]
			)
		);
        $this->add(
            "account",
            new PresenceOf(
                [
                    "message" => "The account is required",
                    // "allowEmpty" => true,
                ]
            )
        );
        $this->add(
            "pwd",
            new PresenceOf(
                [
                    "message" => "The pwd is required",
                    // "allowEmpty" => true,
                ]
            )
        );
        $this->add(
            "role_id",
            new PresenceOf(
                [
                    "message" => "The role_id is required",
                    "allowEmpty" => true,
                ]
            )
        );
        $this->add(
            "mobile",
            new PresenceOf(
                [
                    "message" => "The mobile is required",
                    "allowEmpty" => true,
                ]
            )
        );
        $this->add(
            "creator_id",
            new PresenceOf(
                [
                    "message" => "The creator_id is required",
                    "allowEmpty" => true,
                ]
            )
        );
        $this->add(
            "last_login_time",
            new PresenceOf(
                [
                    "message" => "The last_login_time is required",
                    "allowEmpty" => true,
                ]
            )
        );
    }
	
	//验证之前
	public function beforeValidation($data, $entity, $messages)
    {
    	// $data->creator_id = property_exists($data,'creator_id') ? $data->creator_id : 0;
        return true;
    }
	
}